home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 115 / macaddict115.cdr / Software / Development / REALbasicMacOSX.dmg / REALbasic 2005 Release 4 / Read Me / FileType Read Me.txt < prev    next >
Text File  |  2005-05-18  |  4KB  |  66 lines

  1. REALbasic 6 includes a new class for representing file types.  This file provides preliminary documentation.
  2.  
  3.  
  4. FileType Class
  5. --------------
  6. This class represents a file type.
  7.  
  8. Super: Object
  9.  
  10.  
  11. Properties:
  12.  
  13. Extensions as String: the file extension for this file, or several file extensions separated by semicolons, e.g.: "jpg;jpeg".  A period before each file extension is allowed but not necessary.
  14.  
  15. Icon as Picture (read-only): the icon associated with this file type in the IDE, if any.  (This property does not apply to dynamically created FileTypes.)
  16.  
  17. MacCreator as String: the four-byte string used to represent the application that owns the file in Mac OS.
  18.  
  19. MacType as String: the four-byte string used to indentify the type of the file in Mac OS.
  20.  
  21. Name as String: the name by which this file type will be known to other parts of the REALbasic framework, and as shown to the user in some file dialogs.
  22.  
  23.  
  24. Operators:
  25.  
  26. The FileType class has a conversion-to-string operator, so that you can use a FileType object anywhere you need a string.  It also has addition operators that let you add two FileTypes, or a FileType and a string, to get a string.  The result is the name of the FileType joined with the other one (or the string) via a semicolon -- exactly the format needed by functions like GetOpenFolderItem.
  27.  
  28.  
  29. Example:
  30.  
  31. The following example dynamically creates two FileTypes, one for JPEG files and one for PNG files.  It then presents an Open File dialog that allows selection of just those two types.
  32.  
  33.   Dim jpegType As New FileType
  34.   jpegType.Name = "image/jpeg"
  35.   jpegType.MacType = "JPEG"
  36.   jpegType.Extension = "jpg;jpeg"
  37.   
  38.   Dim pngType As New FileType
  39.   pngType.Name = "image/png"
  40.   pngType.MacType = "PNG "
  41.   pngType.Extension = "png"
  42.   
  43.   Dim f As FolderItem
  44.   f = GetOpenFolderItem( jpegType + pngType )
  45.  
  46.  
  47. File Types in the IDE
  48. ---------------------
  49. REALbasic 6 has a new way of managing file types in your project.  There is a new type of file item called a "Ffile type set."  Within a file type set, you can define one or more file types, and then refer to these by name in your code.
  50.  
  51. Add a new file type set by using the Add submenu of the Project menu, and choosing the File Type Set command.  You can name this whatever you wish using the Project tab, and then add one or more file type definitions within it using the Add File Type button within the editor for that set.
  52.  
  53. Each file type is presented in the editor as one line in a listbox.  Most columns should be self-explanatory, but note that "Display Name" is the name shown to the user on some platforms (e.g. Windows), and also used to identify the file type in functions like GetOpenFolderItem.  "Object Name" is the REALbasic identifier used to refer to the FileType object from within your code.
  54.  
  55. As an example, suppose you make a file type set called "ImageTypes," and within that, you define a type with an Object Name of "JPEG" and another type whose Object Name is "MacPICT."  You could then make use of these in your code this way:
  56.  
  57.   f = GetOpenFolderItem( ImageTypes.JPEG + ImageTypes.MacPICT )
  58.  
  59. In addition, there is a property called "All" which returns the string representing all of the types in that set.  So to continue our previous example, if you really wanted to allow opening of any type defined in the ImageTypes set, you could simply write:
  60.  
  61.   f = GetOpenFolderItem( ImageTypes.All )
  62.  
  63. This has the advantage that if you later decide to add more types to the set, all code written in this way will automatically use the new types.
  64.  
  65. Note that icons are not yet supported for file types.
  66.